"use strict"

var Router = require('koa-router');
var config = require('../../config/config.js');
var debug = require('debug')('router_comment');

debug('router:' + config.http.baseUrl + '/v1/comment');
var router = new Router({
	prefix: config.http.baseUrl + '/v1/comment'
});


var __mockData = [{
	author: "Pete Hunt",
	text: "remote: comment xx"
}, {
	author: "Jordan Walke",
	text: "remote: *another* comment"
}];

router.get('/list', function*() {
	debug('%s %s', this.method, this.url);
	this.body = __mockData;
});

router.post('/', function*() {
	debug('%s %s', this.method, this.url);
	var inParams = this.request.inParams;
	var newComment = {
		author: inParams.author,
		text: inParams.text
	}
	__mockData.push(newComment);
	this.body = __mockData;
	// this.body = [newComment];
	// this.body = newComment;
});

module.exports = router.routes();